package com.bishe.demo.config;


import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyConfig implements WebMvcConfigurer {
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/Manage_account.html").setViewName("Manage_account");
        registry.addViewController("/login.html").setViewName("login");
        registry.addViewController("/index.html").setViewName("index");
        registry.addViewController("/").setViewName("login");
        registry.addViewController("/Manage_developing.html").setViewName("Manage_developing");
        registry.addViewController("/Manage_jiaoyi.html").setViewName("Manage_jiaoyi");
        registry.addViewController("/Manage_dianshi.html").setViewName("Manage_dianshi");
        registry.addViewController("/Manage_pinkun.html").setViewName("Manage_pinkun");

    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //注册TestInterceptor拦截器
        InterceptorRegistration registration = registry.addInterceptor(new WebConfig());
        registration.addPathPatterns("/**")
                .excludePathPatterns("/")
                .excludePathPatterns("/receivePwd")
                .excludePathPatterns("/*/*.js")
                .excludePathPatterns("/*/*.html")
                .excludePathPatterns("/*/*.css")
                .excludePathPatterns("/*/*.jpg")
                .excludePathPatterns("/*/*.png")
                .excludePathPatterns("/*/*.gif");


    }
//    @Bean
//    public FilterRegistrationBean filterRegistrationBean() {
//
//        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
//        //指定要加载的过滤器
//        filterRegistrationBean.setFilter(new );
//
//    }

}
